<?php

namespace App\Logging;

use Illuminate\Log\Logger;

class CustomizeFormatter
{
    /**
     * 自定义给定的日志记录器实例。
     *
     * @param Logger $logger
     */
    public function __invoke(Logger $logger): void
    {
        foreach ($logger->getHandlers() as $handler) {
            $handler->setFormatter(new CustomizeLineFormatter(
                "[%datetime%] %channel%.%level_name%: [%request_id%] [%ip%] [%method%] [%path%] %param% %message% %context% %extra%\n",
                'Y-m-d H:i:s.v',
                false,
                true
            ));
        }
    }
}
